package com.simoniu.first;

import java.io.*;
import javax.servlet.ServletException;
import javax.servlet.http.*;
import javax.servlet.annotation.*;

//精确匹配
@WebServlet(name = "helloServlet", urlPatterns ={"/hello","/haha","/hehe"} ,loadOnStartup = 1)
public class HelloServlet extends HttpServlet {

    public HelloServlet(){
        System.out.println("执行了HelloServlet的构造方法...");
    }

    public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException,IOException {
        doPost(request,response);

    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        response.setContentType("text/html;charset=utf-8");
        PrintWriter out = response.getWriter();
        out.println("<h1>HelloServlet</h1>");
        out.flush();
        out.close();
    }

    public void destroy() {
    }
}